<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>OpenMesh: Notes on template programming</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="logo_align.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="rwth_vci_rgb.jpg"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">OpenMesh
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('a04319.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Notes on template programming </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>Please note, that OpenMesh makes heavily use of C++ templates, generic programming and all that stuff (see <a class="el" href="a04321.html">Some words on the C++ implementation</a>).</p>
<p>Therefore read this section carefully (else you get lost in the reference manual):</p>
<h3>There is no such thing like the OpenMesh class</h3>
<p>The library provides a set of classes ( 99% templates ;-) ), where the inheritance relationship is given by template parameterization. You might ask: "What the heck is that?" It means, a parent class is passed as a template argument to another class:</p>
<div class="fragment"><div class="line"><span class="keyword">class </span>P1 { }</div><div class="line"><span class="keyword">class </span>P2 { }</div><div class="line"><span class="keyword">template</span> &lt;<span class="keyword">typename</span> Parent&gt; <span class="keyword">class </span>B : <span class="keyword">public</span> Parent {}</div><div class="line"></div><div class="line"><span class="keyword">typedef</span> B&lt;P1&gt; fooB1;</div><div class="line"><span class="keyword">typedef</span> B&lt;P2&gt; fooB2;</div></div><!-- fragment --><p>Voila, we have created two different types of B. Depending on the interface, the public member elements, provided by <code>P1</code> or <code>P2</code>, <code>fooB1</code> and <code>fooB2</code> might have different behaviours or even different interfaces! But if <code>P1</code> and <code>P2</code> have the some interface or at least a common interface, then from programming point of view there is no difference using <code>fooB1</code> or <code>fooB2</code>. And this is all about. OpenMesh defines an interface concept for the kernel which is documented in <a class="el" href="a01877.html">OpenMesh::Concepts::KernelT</a>. As long as the kernel provides this the class handling polygonal meshes <code><a class="el" href="a02389.html" title="Base type for a polygonal mesh. ">OpenMesh::PolyMeshT</a></code> can use any kernel.</p>
<h3>Therefore documentation resides in two spaces</h3>
<ol type="1">
<li>Associated with the class/struct (as usual)</li>
<li>In a concept class in cases like the example code above. Hence, if you want to know what a mesh type has to offer refer to <a class="el" href="a01877.html" title="This class describes the minimum interface a mesh kernel has to implement (because the resulting mesh...">OpenMesh::Concepts::KernelT</a>, <a class="el" href="a02389.html" title="Base type for a polygonal mesh. ">OpenMesh::PolyMeshT</a>, <a class="el" href="a02489.html" title="Base type for a triangle mesh. ">OpenMesh::TriMeshT</a>. </li>
</ol>
</div></div><!-- contents -->
</div><!-- doc-content -->
<hr>
<address>
<small>
<a href="http://www.rwth-graphics.de" style="text-decoration:none;">
</a>
Project <b>OpenMesh</b>, 
&copy;&nbsp; Computer Graphics Group, RWTH Aachen.
Documentation generated using 
<a class="el" href="http://www.doxygen.org/index.html">
<b>doxygen</b>
</a>.
</small>
</address>
</body>
</html>
